package com.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.GateDao;
import com.pojo.Gate;
import com.util.ValidateHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;

@Service
public class GateService extends ServiceImpl<GateDao, Gate> {


    @Autowired
    private GateDao gateDao;

    /**
     * 判断员工是否能开门
     * @param cardNo
     * @return
     */
    public boolean canOpenDoor(String cardNo) throws ParseException {

        return false ;
    }



    /**
     * 分页获取闸机信息
     * @param sno 闸机编号
     * @param page
     * @param limit
     * @return
     */
    public IPage<Gate> getPager(String sno, Integer page, Integer limit) {
        Page p = new Page(page, limit);
        QueryWrapper q = new QueryWrapper();
        if (ValidateHelper.isNotEmptyString(sno)) {
            q.like("sno", sno);
        }
        IPage<Gate> iPage = gateDao.selectPage(p, q);
        return iPage;
    }

}
